package com.boot.system.controller;

import com.boot.common.anno.AnnoLog;
import com.boot.common.anno.RepeatSubmit;
import com.boot.common.result.Result;
import com.boot.system.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequiredArgsConstructor
@RestController
@RequestMapping("/log")
public class LogController {

    private final LogService logService;

    @AnnoLog(value = "日志列表")
    @PostMapping("/list")
    public Result<?> userList(@RequestBody Map<String, Object> queryParam) {
        return Result.success(logService.getLogPage(queryParam));
    }

    @AnnoLog(value = "日志删除")
    @RepeatSubmit
    @PostMapping("/delete")
    public Result<?> deleteLog(@RequestBody Map<String, Object> dataParam) {
        return Result.success(logService.deleteLog(dataParam.get("ids").toString()));
    }

    @AnnoLog(value = "日志清空")
    @RepeatSubmit
    @PostMapping("/clear")
    public Result<?> clearLog() {
        return Result.success(logService.clearLog(0));
    }

}
